package org.obs.domain;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "ENTRY")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Entry implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
	private EntryBody entryBody;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	protected EntryBody getEntryBody() {
		if (this.entryBody == null) {
			this.entryBody = new EntryBody();
		}
		return entryBody;
	}

	protected void setEntryBody(EntryBody body) {
		this.entryBody = body;
	}
	
	public void setBody(String body) {
		this.getEntryBody().setBody(body);
	}

	public String getBody() {
		return this.getEntryBody().getBody();
	}
}
